//------------------------------------------------------------------------
// Abstract: Define of class Console
//
// Authoring: XiaoHanxiong
//
// Time: 2013.12.08
//
// Static test:
//
// Version history:
//		Ver_1.0	: 2013.12.08	XiaoHanxiong
//		Ver_1.1 : 2013.12.30	XiaoHanxiong
//------------------------------------------------------------------------
#ifndef __Library_Console_h_
#define __Library_Console_h_

#include "Stdafx.h"

namespace Library
{
#define BLUE	0x0001
#define GREEN	0x0002
#define RED		0x0004
#define WHITE	0x0007

	class _LIBRARY Console
	{
	private:
		// Constructor
		Console();
		// Destructor
		~Console();

	public:
		// Get the global only one reference
		static Console& GetReference();

	/* Common operation */
	public:
		// To set the time information output or not
		void SetTimeFlag(bool flag);
	private:
		// To set output color
		void SetColor(int color);
		// Get the current time of local machine
		void GetTime(char* buf);
		// The flag for output time
		static bool time_flag;
		// The flag for initialization or not
		static bool init_flag;

	/* Ordinary i/o operation */
	public:
		// Initialize
		static void Initialize(string log_fname, string error_fname);
		// Output error information
		void Error(char* fmt, ...);
		// Output log information
		void Log(char* fmt, ...);
	private:
		// The log *.txt handle
		static ofstream log_file;
		// The error *.txt handle
		static ofstream error_file;
		// The save path of log and error's common *.txt 
		static string basic_path;
		// The flag for output log into file
		static bool log_flag;
		// The flag for output error into file
		static bool error_flag;


		// Extend i/o
	public:
		void InitialzeEx();
		void Printf();
	};

}// _Library_

#endif